package dp;

import 工具函数模板.快递分拣;

import java.util.Scanner;

public class 小明的背包3 {
    static int num;
    static int V;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        num = scanner.nextInt();
        V = scanner.nextInt();
        int[] w = new int[num + 1];
        int[] v = new int[num + 1];
        int[] s = new int[num + 1];
        for (int i = 1; i <= num; i++) {
            w[i] = scanner.nextInt();
            v[i] = scanner.nextInt();
            s[i] = scanner.nextInt();
        }

        int[][] dp = new int[num + 1][V + 1];
        for (int i = 1; i <= num; i++) {
            for (int j = 1; j <= V; j++) {
                //依次考虑物品不同的数量
                for (int k = 1; k <= s[i] && k * w[i] <= j; k++) {
                    dp[i][j] =Integer.max(dp[i][j],dp[i-1][j-k*w[i]+k*v[i]]);
                }
            }
        }

        System.out.println(dp[num][V]);
    }
}
